<%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" errorPage="~/Error.aspx" Codebehind="UserProfile.aspx.cs"
    Inherits="SecurityLinkUp.UserProfile" Title="UserProfile" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Assembly="PietschSoft.VE" Namespace="PietschSoft.VE" TagPrefix="PietschSoftVE" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder" runat="server">

    <script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5"></script>

    <script type="text/javascript">      
      var Map = null;      

      function GetMap()
      {
        Map = new VEMap('ctl00_ContentPlaceHolder_Map'); 
        Map.SetDashboardSize(VEDashboardSize.Tiny); 
        Map.LoadMap(new VELatLong(0,0), 0, 'r', false,VEMapMode.Mode2D, false);
        //Map.Clear();
        // resize is required in this instance to force the map to size correctly on the page
        Map.Resize(400,400);
      } 
      
      function RefreshMap()
      {
        //GetMap();
      }
  
      function FindLocation (loc)
      {
        try
        {
            var loc = document.getElementById("ctl00_ContentPlaceHolder_GeoArea").value;
        
            if (loc != "")
            {
                GetMap();
                var resultslayer = new VEShapeLayer();
                Map.AddShapeLayer(resultslayer);
                Map.Find('', loc, VEFindType.Businesses, resultslayer, 0, 5, true, true, false, true, ProcessResults);
             }
        }
        catch (e)
        {
            alert(e.message);
        }
      }              
                
      
      function ProcessResults(layer, findResults, places, hasmore)
      {
            for (resultID in places)
            {                
                var latitude = places[resultID].LatLong.Latitude;
                var longitude = places[resultID].LatLong.Longitude;                
                AddPushpin(resultID, latitude, longitude, places[resultID].Name, GenerateDescription(latitude, longitude));
            }
      }
      
      function AddPushpin(pinId, latitude, longitude, title, details)
      {
        var vell = new VELatLong(latitude, longitude);
        var pp = new VEPushpin(pinId, vell, null , title, details, 'pushpin');
        Map.AddPushpin(pp);       
      } 
      
      function GenerateDescription(Lat, Long)
      {
           var link = '<a href=\"javascript:SetLatLongValues(\'';           
           link +=Lat;
           link +='\', \'';
           link +=Long;
           link +='\')\"> Set this point as location </a>';
           return link;
      }
      
      function SetLatLongValues(Lat, Long)
      {
         document.getElementById("ctl00_ContentPlaceHolder_GeoLat").value = Lat;
         document.getElementById("ctl00_ContentPlaceHolder_GeoLong").value = Long;
         document.getElementById("ctl00_ContentPlaceHolder_LocationStatusImg").src = "/images/check.png"; 
      }

    </script>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <Triggers>
            <asp:PostBackTrigger ControlID="SaveBtn" />
        </Triggers>
        <ContentTemplate>
            <table>
                <tr>
                    <td valign="top">
                        Username</td>
                    <td valign="top">
                        <asp:Label ID="Username" runat="server" Text="Label"></asp:Label>&nbsp;
                        <asp:LinkButton ID="ChangePasswordLnk" runat="server">Change Password</asp:LinkButton><br />
                        <br />
                    <asp:Label ID="ChangePasswordErrorMessage" runat="server" CssClass="ErrorMessage" Visible="False"></asp:Label></td>
                    <td valign="top" rowspan="9">
                        <PietschSoftVE:Map runat="server" ID="Map" Width="400" Height="400" Zoom="0" Latitude="20.0"
                            Longitude="10.0" ShowDashboard="False" />
                        <asp:HiddenField ID="GeoLat" runat="server" />
                        <asp:HiddenField ID="GeoLong" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td valign="top">
                        Email</td>
                    <td valign="top">
                        <asp:TextBox ID="Email" runat="server"></asp:TextBox></td>
                </tr>
                <tr>
                    <td valign="top">
                        Allow Email</td>
                    <td valign="top">
                        <asp:CheckBox ID="allowemailchk" runat="server" /><br />
                        <small>
                            <br />[Checking this box allows users to directly email you.  Having it
                        unchecked means that your email will not be disclosed, but users can still
                        contact you via a "send to" form on this website]</td>
                </tr>
                <tr>
                    <td valign="top">
                        Real name</td>
                    <td valign="top">
                        <asp:TextBox ID="RealName" runat="server"></asp:TextBox></td>
                </tr>
                <tr>
                    <td valign="top">
                        Job Title</td>
                    <td valign="top">
                        <asp:TextBox ID="JobTitle" runat="server"></asp:TextBox></td>
                </tr>
                <tr>
                    <td valign="top">
                        Company</td>
                    <td valign="top">
                        <asp:TextBox ID="Company" runat="server"></asp:TextBox></td>
                </tr>
                <tr>
                    <td valign="top">
                        Picture</td>
                    <td valign="top">
                        <asp:Image ID="UserPicture" runat="server" /><br />
                        <br />
                        <small>Upload new image</small></br />
                        <asp:FileUpload ID="NewPicture" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td valign="top" style="width: 110px">
                        Geographic Area<br />
                        <small>[Set where you are located - optional]</small></td>
                    <td style="width: 194px" valign="top">
                        <asp:TextBox ID="GeoArea" runat="server" Width="159px"></asp:TextBox>
                        <input type="button" id="FindChapterBtn" value="Find" onclick="FindLocation()" />
                    </td>
                </tr>
                <tr>
                    <td valign="top" style="width: 110px">
                        Location Encoded
                    </td>
                    <td style="width: 194px" valign="top">
                        <asp:Image ID="LocationStatusImg" ImageUrl="~/Images/cross.png" runat="server" ImageAlign="Top" />
                        <div>
                            <small>[Hover over map pins to set location]</small></div>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="right">
                        <asp:Button ID="SaveBtn" runat="server" Text="Save" OnClick="SaveBtn_Click" />
                        <br />
                        <asp:Label ID="ErrorMessage" CssClass="ErrorMessage" runat="server"></asp:Label>
                    </td>
                </tr>
            </table>
            
            <br />
        <cc1:ModalPopupExtender ID="ChangePasswordPopup" runat="server"
            TargetControlID="ChangePasswordLnk"
            PopupControlID="ChangePasswordPanel" 
            BackgroundCssClass="modalBackground" 
            DropShadow="false" />
        <br />
        <asp:Panel ID="ChangePasswordPanel" cssclass="WarningPopup" style="display:none;" runat="server" Width="350px">
        <table>
        <tr><td>Current Password</td><td><asp:TextBox ID="CurrentPassword" TextMode="Password" runat="server" /></td></tr>
        <tr><td>New Password</td><td><asp:TextBox ID="NewPassword" TextMode="Password" runat="server" />
        <cc1:PasswordStrength ID="PasswordStrength" runat="server" StrengthIndicatorType="Text"
                            PreferredPasswordLength="10" PrefixText="Strength:" TextCssClass="PasswordStrength"
                            MinimumNumericCharacters="1" MinimumSymbolCharacters="1" RequiresUpperAndLowerCaseCharacters="true"
                            TextStrengthDescriptions="Poor;Weak;Average;Strong;Excellent" TargetControlID="NewPassword">
                        </cc1:PasswordStrength></td></tr>
        <tr><td>Confirm Password</td><td><asp:TextBox ID="ConfirmPassword" TextMode="Password" runat="server" /></td></tr>
            <tr>
                <td align="right" colspan="2">
                    </td>
            </tr>
        <tr><td colspan="2" align="right"><asp:Button ID="ConfirmChange" runat="server" Text="Change" OnClick="ConfirmChange_Click"/>&nbsp;
            <asp:Button ID="CancelBtn" runat="server" Text="Cancel" OnClick="CancelBtn_Click" /></td></tr>
        </table>
        </asp:Panel>
            
            
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
